package com.woniuxy.service.impl;

import com.woniuxy.ResponseEntity.ResponseEntity;
import com.woniuxy.dao.RbacMenuDao;
import com.woniuxy.entity.RbacMenu;
import com.woniuxy.service.RbacMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class RbacMenuServiceImpl implements RbacMenuService {
    @Autowired(required = false)
    RbacMenuDao rbacMenuDao;
    @Override
    public ResponseEntity findAllmenu() {
        //调用dao层方法查询数据
        List<RbacMenu> menu = rbacMenuDao.findMenu();
        //创建返回对象
        ResponseEntity<List<RbacMenu>> responseEntity = new ResponseEntity();

        if (menu.size() > 0) {
            responseEntity.setData(menu);
            responseEntity.setCode(200);
            responseEntity.setMessage("查询成功");
            return responseEntity;
        }else {
            responseEntity.setData(null);
            responseEntity.setCode(500);
            responseEntity.setMessage("查询失败");
            return responseEntity;
        }


    }

    @Override
    public ResponseEntity updatedMenu(RbacMenu rbacMenu) {
        int i= rbacMenuDao.updatedMenu(rbacMenu);
        if (i > 0) {
            return new ResponseEntity(200,"修改成功",null);
        }else {
            return new ResponseEntity(500,"修改失败",null);
        }

    }
}
